#include "Common.hpp"
#include "Dict.hpp"
#include "TCPServe.hpp"

std::string DefaultHandle(std::string word,InetAddr&peer)
{
    LOG(INFO)<<"进入到了回调模块";
    std::string s="haha";
    s+=word;
    return s;
}
int main(int argc,char*argv[])
{
    if(argc!=2)
    {
        std::cout<<"请输入正确的参数例如: "<<" ./可执行程序 port"<<std::endl;
        exit(USAGE_ERR);
    }
    //转字符串为数字
    uint16_t port=std::stoi(argv[1]);

    Enable_Console_Sync_Strategy;

    // TCPServe s(port,func());
    // TCPServe s(port,DefaultHandle);
    // Dict d;
    // d.LoadDictionary();
    // std::unique_ptr<TCPServe> tcpuser = std::make_unique<TCPServe>(port,[&d](std::string ec,InetAddr&peer){
    //     // return DefaultHandle(ec,peer);
    //     return d.Translate(ec,peer);
    // });
    Command cmd;
    // std::unique_ptr<TCPServe> tcpuser = std::make_unique<TCPServe>(port,[&cmd](std::string ec,InetAddr&peer){
    //     return cmd.Excute(ec,peer);
    // });
    
    std::unique_ptr<TCPServe> tcpuser = std::make_unique<TCPServe>(port,
        std::bind(&Command::Excute,&cmd,std::placeholders::_1,std::placeholders::_2));
    tcpuser->Init();
    tcpuser->Start();
    return 0;
}